package com.ruoyi.door.controller.admin.orderdetail;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.easy.query.core.api.pagination.EasyPageResult;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.door.controller.admin.orderdetail.vo.DoorOrderDetailPageReqVO;
import com.ruoyi.door.controller.admin.orderdetail.vo.DoorOrderDetailRespVO;
import com.ruoyi.door.service.DoorOrderDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.door.domain.DoorOrderDetail;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【订单明细】Controller
 * 
 * @author ruoyi
 * @date 2025-07-11
 */
@Api(value ="订单明细管理",tags = "订单明细管理")

@RestController
@RequestMapping("/admin-api/door/detail")
public class DoorOrderDetailController extends BaseController
{
    @Autowired
    private DoorOrderDetailService doorOrderDetailService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    @ApiOperation("查询订单信息列表")

    public TableDataInfo list(DoorOrderDetailPageReqVO doorOrderDetail)
    {
        EasyPageResult<DoorOrderDetailRespVO> pageResult = doorOrderDetailService.selectDoorOrderDetailPageList(doorOrderDetail);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(pageResult.getData());
        rspData.setTotal(pageResult.getTotal());
        return rspData;
    }

    /**
     * 导出【订单明细】列表
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出【订单明细】列表")
    public void export(HttpServletResponse response, DoorOrderDetailPageReqVO doorOrderDetail)
    {
        List<DoorOrderDetailRespVO> list = doorOrderDetailService.selectDoorOrderDetailList(doorOrderDetail,null);
        ExcelUtil<DoorOrderDetailRespVO> util = new ExcelUtil<DoorOrderDetailRespVO>(DoorOrderDetailRespVO.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【订单明细】详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取【订单明细】详细信息")

    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doorOrderDetailService.selectDoorOrderDetailById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation("新增【订单明细】")

    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoorOrderDetail doorOrderDetail)
    {
        return toAjax(doorOrderDetailService.insertDoorOrderDetail(doorOrderDetail)>0);
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation("修改【订单明细】")

    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoorOrderDetail doorOrderDetail)
    {
        return toAjax(doorOrderDetailService.updateDoorOrderDetail(doorOrderDetail)>0);
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation("删除【订单明细】")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doorOrderDetailService.deleteDoorOrderDetailByIds(ids)>0);
    }
}
